import Vue from "vue";
import VueI18n from 'vue-i18n'
import locale from 'element-ui/lib/locale';
// import elementEnLocale from 'element-ui/lib/locale/lang/en'
import elementZhLocale from 'element-ui/lib/locale/lang/zh-CN'
import elementViLocale from 'element-ui/lib/locale/lang/vi'
// import elementIdLocale from 'element-ui/lib/locale/lang/id'
import elementMxLocale from './es-mx/elementMX'
import zhCn from './zh-cn/index.js'
import viVn from './vi-vn/index.js'
// import enIn from './en-in/index.js'
// import idId from './id-id/index.js'
import esMX from './es-mx/index'

let timer = null
const obj = zhCn
let conter = {}
Vue.use(VueI18n)
let defaultLocale = localStorage.getItem('locale')
/**
 * localeValue 默认语言
 * zh_CN 中文
 * en_IN 英文
 * vi_VN 越南文
 * id_ID 印尼文
 * es_MX 墨西哥文
 */
let localeValue = defaultLocale || process.env.VUE_APP_LOCAL || 'en_IN'
const i18n = new VueI18n({
    locale: localeValue,
    messages: {
        zh_CN: {
            ...zhCn,
            ...elementZhLocale,
        },
        // en_IN: {
        //     ...elementEnLocale,
        //     ...enIn
        // },
        // id_ID: {
        //     ...idId,
        //     ...elementIdLocale
        // },
        vi_VN: {
            ...elementViLocale,
            ...viVn
        },
        es_MX: {
            ...esMX,
            ...elementMxLocale
        }
    },
    missing: (value, key) => {
        // if (!obj[key]) {
        //     conter[key] = key
        //     if (timer) clearTimeout(timer)
        //     timer = setTimeout(() => {
        //         console.log(JSON.stringify(conter))
        //     }, 200)
        // }
    }
});

locale.i18n((key, value) => i18n.t(key, value))
export default i18n
